#ifndef _MODBUS_INTERFACE_H_
#define _MODBUS_INTERFACE_H_

#include <stdint.h>
#include <stdbool.h>

/********************
function:  Modbus ´Ó»úµØÖ· 
input:     
return:    ´Ó»úµØÖ·
*/
uint8_t Modbus_SlaveAddr_Get(void);
void    Modbus_SlaveAddr_Set(uint8_t addr);

/********************
function:  Modbus ¶ÏÖ¡µ¹¼ÆÊ±
input:     BaudRate Í¨µÀ²¨ÌØÂÊ
return:    Ê±¼ä(µ¥Î»=50us)        e.g.:  [36] x 50us = 1800us
*/
#if 0
	uint16_t Modbus_Ctdw_Calculate(uint32_t BaudRate);
#else
	#define Modbus_Ctdw_Calculate(x)  ((x>19200)?(35):(770000UL / x))
#endif
/********************
 @brief:    ModbusRTU ´Ó»úÄ£Ê½½ÓÊÕÖ¡½âÎö
 @param:    protocoldata¡¢Length  ½ÓÊÕ/Ó¦´ðÖ¡ Ö¡³¤¶È
 @retval:   true or false (modbus½âÎöÕýÈ·²¢Íê³É)
*/
bool API_ModbusRTU_Slave_Analy(char* protocoldata,  uint16_t* Length);

/********************
 @brief:    ModbusTCP ´Ó»úÄ£Ê½½ÓÊÕÖ¡½âÎö
 @param:    protocoldata¡¢Length  ½ÓÊÕ/Ó¦´ðÖ¡ Ö¡³¤¶È
 @retval:   true or false (modbus½âÎöÕýÈ·²¢Íê³É)
*/
bool API_ModbusTCP_Slave_Analy(char* protocoldata,  uint16_t* Length);

/********************
 @brief:    ModbusASCII ´Ó»úÄ£Ê½½ÓÊÕÖ¡½âÎö
 @param:    protocoldata¡¢Length  ½ÓÊÕ/Ó¦´ðÖ¡ Ö¡³¤¶È
 @retval:   true or false (modbus½âÎöÕýÈ·²¢Íê³É)
*/
bool API_ModbusASCII_Slave_Analy(char* protocoldata,  uint16_t* Length);


#endif


